package com.haoran.springboot.config;


import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

/**
 * AbstractWebSocketMessageBrokerConfigurer已过时
 * 目前已用WebSocketMessageBrokerConfigurer接口代替AbstractWebSocketMessageBrokerConfigurer
 */
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) { //注册stomp协议的节点
            registry.addEndpoint("/endpointWisely").withSockJS();//注册stomp的endpint节点,指定使用SockJs协议
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        registry.enableSimpleBroker("/topic");
    }//消息代理
}
